package com.zj.roseoj.judge.codesandbox;

import com.zj.roseoj.judge.codesandbox.model.ExecuteCodeRequest;
import com.zj.roseoj.judge.codesandbox.model.ExecuteCodeResponse;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * 代码沙箱代理类
 */
@Slf4j
@AllArgsConstructor
public class CodeSandBoxProxy implements CodeSandbox{

    /**
     * 只会改变一次，指定为final
     */
    private final CodeSandbox codeSandbox;

    /**
     * 代码增强，执行前后输出日志
     * @param executeCodeRequest
     * @return
     */
    @Override
    public ExecuteCodeResponse executeCode(ExecuteCodeRequest executeCodeRequest) {
        log.info("代码沙箱请求信息：" + executeCodeRequest.toString());
        ExecuteCodeResponse executeCodeResponse = codeSandbox.executeCode(executeCodeRequest);
        log.info("代码沙箱响应信息：" + executeCodeResponse.toString());
        return executeCodeResponse;
    }
}
